home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / sndhrdw / pulsar.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  3KB  |  173 lines

  1. /*
  2.  *    Pulsar sound routines
  3.  *
  4.  *    TODO: change heart rate based on bit 7 of Port 1
  5.  *
  6.  */
  7.  
  8. #include "driver.h"
  9.  
  10.  
  11. /* output port 0x01 definitions - sound effect drive outputs */
  12. #define OUT_PORT_1_CLANG        0x01
  13. #define OUT_PORT_1_KEY            0x02
  14. #define OUT_PORT_1_ALIENHIT        0x04
  15. #define OUT_PORT_1_PHIT            0x08
  16. #define OUT_PORT_1_ASHOOT        0x10
  17. #define OUT_PORT_1_PSHOOT        0x20
  18. #define OUT_PORT_1_BONUS        0x40
  19. #define OUT_PORT_1_HBEAT_RATE    0x80    /* currently not used */
  20.  
  21. /* output port 0x02 definitions - sound effect drive outputs */
  22. #define OUT_PORT_2_SIZZLE        0x01
  23. #define OUT_PORT_2_GATE            0x02
  24. #define OUT_PORT_2_BIRTH        0x04
  25. #define OUT_PORT_2_HBEAT        0x08
  26. #define OUT_PORT_2_MOVMAZE        0x10
  27.  
  28.  
  29. #define PLAY(id,loop)           sample_start( id, id, loop )
  30. #define STOP(id)                sample_stop( id )
  31.  
  32.  
  33. /* sample file names */
  34. const char *pulsar_sample_names[] =
  35. {
  36.     "*pulsar",
  37.     "clang.wav",
  38.     "key.wav",
  39.     "alienhit.wav",
  40.     "phit.wav",
  41.     "ashoot.wav",
  42.     "pshoot.wav",
  43.     "bonus.wav",
  44.     "sizzle.wav",
  45.     "gate.wav",
  46.     "birth.wav",
  47.     "hbeat.wav",
  48.     "movmaze.wav",
  49.     0
  50. };
  51.  
  52. /* sample sound IDs - must match sample file name table above */
  53. enum
  54. {
  55.     SND_CLANG = 0,
  56.     SND_KEY,
  57.     SND_ALIENHIT,
  58.     SND_PHIT,
  59.     SND_ASHOOT,
  60.     SND_PSHOOT,
  61.     SND_BONUS,
  62.     SND_SIZZLE,
  63.     SND_GATE,
  64.     SND_BIRTH,
  65.     SND_HBEAT,
  66.     SND_MOVMAZE
  67. };
  68.  
  69.  
  70. static int port1State = 0;
  71.  
  72. WRITE_HANDLER( pulsar_sh_port1_w )
  73. {
  74.     int bitsChanged;
  75.     int bitsGoneHigh;
  76.     int bitsGoneLow;
  77.  
  78.  
  79.     bitsChanged  = port1State ^ data;
  80.     bitsGoneHigh = bitsChanged & data;
  81.     bitsGoneLow  = bitsChanged & ~data;
  82.  
  83.     port1State = data;
  84.  
  85.     if ( bitsGoneLow & OUT_PORT_1_CLANG )
  86.     {
  87.         PLAY( SND_CLANG, 0 );
  88.     }
  89.  
  90.     if ( bitsGoneLow & OUT_PORT_1_KEY )
  91.     {
  92.         PLAY( SND_KEY, 0 );
  93.     }
  94.  
  95.     if ( bitsGoneLow & OUT_PORT_1_ALIENHIT )
  96.     {
  97.         PLAY( SND_ALIENHIT, 0 );
  98.     }
  99.  
  100.     if ( bitsGoneLow & OUT_PORT_1_PHIT )
  101.     {
  102.         PLAY( SND_PHIT, 0 );
  103.     }
  104.  
  105.     if ( bitsGoneLow & OUT_PORT_1_ASHOOT )
  106.     {
  107.         PLAY( SND_ASHOOT, 0 );
  108.     }
  109.  
  110.     if ( bitsGoneLow & OUT_PORT_1_PSHOOT )
  111.     {
  112.         PLAY( SND_PSHOOT, 0 );
  113.     }
  114.  
  115.     if ( bitsGoneLow & OUT_PORT_1_BONUS )
  116.     {
  117.         PLAY( SND_BONUS, 0 );
  118.     }
  119. }
  120.  
  121.  
  122. WRITE_HANDLER( pulsar_sh_port2_w )
  123. {
  124.     static int port2State = 0;
  125.     int bitsChanged;
  126.     int bitsGoneHigh;
  127.     int bitsGoneLow;
  128.  
  129.  
  130.     bitsChanged  = port2State ^ data;
  131.     bitsGoneHigh = bitsChanged & data;
  132.     bitsGoneLow  = bitsChanged & ~data;
  133.  
  134.     port2State = data;
  135.  
  136.     if ( bitsGoneLow & OUT_PORT_2_SIZZLE )
  137.     {
  138.         PLAY( SND_SIZZLE, 0 );
  139.     }
  140.  
  141.     if ( bitsGoneLow & OUT_PORT_2_GATE )
  142.     {
  143.         sample_start( SND_CLANG, SND_GATE, 0 );
  144.     }
  145.     if ( bitsGoneHigh & OUT_PORT_2_GATE )
  146.     {
  147.         STOP( SND_CLANG );
  148.     }
  149.  
  150.     if ( bitsGoneLow & OUT_PORT_2_BIRTH )
  151.     {
  152.         PLAY( SND_BIRTH, 0 );
  153.     }
  154.  
  155.     if ( bitsGoneLow & OUT_PORT_2_HBEAT )
  156.     {
  157.         PLAY( SND_HBEAT, 1 );
  158.     }
  159.     if ( bitsGoneHigh & OUT_PORT_2_HBEAT )
  160.     {
  161.         STOP( SND_HBEAT );
  162.     }
  163.  
  164.     if ( bitsGoneLow & OUT_PORT_2_MOVMAZE )
  165.     {
  166.         PLAY( SND_MOVMAZE, 1 );
  167.     }
  168.     if ( bitsGoneHigh & OUT_PORT_2_MOVMAZE )
  169.     {
  170.         STOP( SND_MOVMAZE );
  171.     }
  172. }
  173.